package com.question.business.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.question.business.user.entity.UserPost;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户岗位Mapper接口
 *
 * @author star
 * @since 2023-09-14
 */
@Mapper
public interface UserPostMapper extends BaseMapper<UserPost> {

    /**
     * 用户岗位查询
     *
     * @param userId 用户ID
     * @return List<String> 响应参数
     */
    @Select("SELECT post_id FROM t_user_post WHERE user_id = #{userId}")
    List<String> queryPostByUserId(String userId);

    /**
     * 岗位用户查询
     *
     * @param postId 岗位ID
     * @return List<String> 响应参数
     */
    @Select("SELECT user_id FROM t_user_post WHERE post_id = #{postId}")
    List<String> queryUserByPostId(String postId);

    /**
     * 根据用户ID删除岗位
     *
     * @param userId 用户ID
     */
    @Delete("DELETE FROM t_user_post WHERE user_id = #{userId}")
    void deleteByUserId(String userId);

    /**
     * 根据岗位ID删除用户
     *
     * @param postId 岗位ID
     */
    @Delete("DELETE FROM t_user_post WHERE post_id = #{postId}")
    void deleteByPostId(String postId);

}